﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Comm;
using VK.Casemeet.Merchants;

namespace VK.Casemeet.Web.ShopAdmin
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void butLogin_Click(object sender, EventArgs e)
        {
            string strMessage = "";
            if (txtName.Text.Trim().Length == 0)
            {
                strMessage += "----用户名不能为空!\\n";
            }
            if (txtPass.Text.Trim().Length == 0)
            {
                strMessage += "----密　码不能为空!\\n";
            }
            if (txtCode.Text.Trim().Length == 0)
            {
                strMessage += "----验证码不能为空!\\n";
            }
            if (Util.GetCookieString("AdminValidateCode") != txtCode.Text.ToLower())
            {
                strMessage += "----验证码输入错误!\\n";
            }
            if (strMessage.Length != 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script>alert('" + strMessage + "');</script>");
                return;
            }

            switch (AdminBLL.Enter(txtName.Text, DES.Encrypt(txtPass.Text, CS.ShopAdminPassKey), chkState.Checked))
            {
                case 1: Response.Redirect("/ShopAdmin/Home.aspx"); break;
                case 2: Message.Msg(this.Page, "用户帐号不存在!", MessageType.Failure); break;
                case 3: Message.Msg(this.Page, "用户密码错误!", MessageType.Failure); break;
            }
        }
    }
}